<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>

        * {
            box-sizing: border-box;
        }

        .bg-img {
            background-image: url("../img/bg2.jpeg");
            min-height: 380px;
            border: 1px solid red;
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
            position: relative;
        }

        .container {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            width: auto;
        }

        /* The navbar */
        .topnav {
            overflow: hidden;
            background-color: lightgoldenrodyellow;
        }

        /* Navbar links */
        .topnav a {
            float: left;
            color: black;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
            font-size: 17px;
        }

        .topnav a:hover {
            background-color: #ddd;
            color: black;
        }
    </style>
</head>

<body>

    <h2>Navbar on Image</h2>

    <div class="bg-img">
        <div class="container">
            <div class="topnav">
                <a href="#home">Home</a>
                <a href="#contact">Contact</a>
                <a href="#about">About</a>
            </div>
        </div>
    </div>



    	
<xmp style="font-size: 22px; font-weight: bolder;  margin-bottom: 66px;  color: black;  font-family: '微软雅黑';">   
    
        必知必会

        <div class="bg-img">
            <div class="container">
                <div class="topnav">
                    <a href="#home">Home</a>
                    <a href="#contact">Contact</a>
                    <a href="#about">About</a>
                </div>
            </div>
        </div>

        
        这里用到了
        .bg-img {
            background-image: url(img/bg2.jpeg);
            min-height: 380px;
            border: 1px solid red;
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
            position: relative;
        }

        .container {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            width: auto;
        }
    </xmp>



    <h1 style="height: 100px;">asdasd</h1>
    <h1 style="height: 100px;">asdasd</h1>
    <h1 style="height: 100px;">asdasd</h1>
</body>
</html>